package com.java.escape.springproblem.controller;

import com.java.escape.springproblem.applicationcontext.ApplicationContextStore;
import com.java.escape.springproblem.bean_post_processor.DecoderManager;
import com.java.escape.springproblem.bean_post_processor.VideoType;
import com.java.escape.springproblem.enums.TestEnum;
import com.java.escape.springproblem.service.CCDontextLoadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName TestController
 * @Description TODO
 * @Author wyp
 * @Date 2023/9/11 14:02
 * @Version 1.0
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired()
    private CCDontextLoadService ccDontextLoadService;


    @RequestMapping("/one")
    public void test(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setHeader("Content-Type", "text/plain");
//        response.sendError(404, "错误");
        response.setContentType("text/plain");
        response.setStatus(200);
        response.getWriter().print(ApplicationContextStore.getApplicationContext().getBean("CCDontextLoadService"));
    }

    @Autowired
    private DecoderManager decoderManager;

    @RequestMapping("/two")
    public void testDecoderManager(HttpServletResponse response) throws IOException {
        String decode = decoderManager.decode(VideoType.AVI, "avi");
        response.getWriter().print(decode);
    }
}
